package com.jd.service;

import com.jd.mapper.AdminMapper;
import com.jd.pojo.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class AdminServiceImpl implements AdminService{
    @Autowired
    private AdminMapper adminMapper;

    @Override
    public String login(Admin admin) {
//        String password = admin.getPassword();
//        byte[] bytes = password.getBytes();
        //1.将密码加密
//        String md5Password = DigestUtils.md5DigestAsHex(bytes);
//        admin.setPassword(md5Password);
        //2.根据用户名和密码查询数据库
        Admin adminDB = adminMapper.findAdminByUP(admin);
        if (adminDB==null){
            return null;
        }
        String token = UUID.randomUUID().toString();
        return token;
    }

    @Override
    public Admin selectAll(Integer id) {
        return adminMapper.selectById(id);
    }
}
